package cc.wsyw126.java.jvm;

/**
 * Created by junpeng.yang on 17/3/9.
 */

import java.util.List;
import java.util.ArrayList;

/**
 * Java堆溢出
 * VM Args：-Xms5M -Xmx5M -Xmn2M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/Users/yangdp/Desktop/jvm/hprof -Xloggc:/Users/yangdp/Desktop/jvm/log -XX:+PrintGCDateStamps -XX:+PrintGCDetails
 */

public class HeapOOM {

    public static void main(String[] args) {
        List<OOMObject> list = new ArrayList<OOMObject>();
        while (true) {
            // list保留引用，避免Full GC 回收
            list.add(new OOMObject());
        }
    }

    static class OOMObject {

    }
}
